package com.atguigu.gulimall.order.vo;

//订单确认vo

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@ToString
public class OrderConfirmVo {

    //    收货地址
    @Getter
    @Setter
    List<MemberAddressVo> address;

    //    购物车清单
    @Getter
    @Setter
    List<OrderItemVo> items;

//    发票信息

    //    优惠卷信息
    @Getter
    @Setter
    Integer integration;

    Integer count;

    public Integer getCount() {
        return items.size();
    }

    @Getter
    @Setter
    Map<Long, Boolean> stocks;


    BigDecimal total; // 订单总额

    public BigDecimal getTotal() {
        BigDecimal all = new BigDecimal("0");
        if (items != null && items.size() > 0) {
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount() + ""));
                all = all.add(multiply);
            }
        }
        this.total = all;
        return total;
    }

    public BigDecimal getPayPrice() {
        this.payPrice = getTotal();
        return payPrice;
    }

    BigDecimal payPrice; //应付价格

    //TODO: 唯一令牌（放重复令牌）
    @Getter @Setter
    private String orderToken;


}
